package operation;

import abbot.finder.ComponentNotFoundException;
import abbot.finder.MultipleComponentsFoundException;
import abbot.finder.matchers.NameMatcher;
import com.supermap.desktop.controls.ControlsProperties;
import com.supermap.desktop.core.properties.CoreProperties;

import java.awt.*;

import static operation.RibbonOperation.RIBBONOPERATION;

/**
 * Created by hanyz on 2017/10/27.
 */
public class ModelOperation {
	//打开建模面板
	public static void startModeling() throws ComponentNotFoundException, MultipleComponentsFoundException {
		RIBBONOPERATION.clickButton("可视化建模", "新建");
	}

	public static void runWorkFlow() throws ComponentNotFoundException, MultipleComponentsFoundException {
		RIBBONOPERATION.clickButton("可视化建模", "执行");
	}

	//选择指定名称数据集，不负责激活面板，不负责选择数据源
	public static void selectSourceDataset(String datasetName) throws ComponentNotFoundException, MultipleComponentsFoundException {
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		Component sourceDatasetGroup = dockbarOperation.searchComponent(new NameMatcher(ControlsProperties.getString("String_GroupBox_SourceDataset")));
		new Operation((Container) sourceDatasetGroup).setComboBoxSelectedItem(new NameMatcher(CoreProperties.getString(CoreProperties.Label_Dataset)), datasetName);
	}

	//设置结果数据集名称
	public static void setResultDatasetName(String datasetName) throws ComponentNotFoundException, MultipleComponentsFoundException {
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		Component datasetGroup = dockbarOperation.searchComponent(new NameMatcher(CoreProperties.getString("String_GroupBox_ResultData")));
		new Operation((Container) datasetGroup).setTextComponentValue(new NameMatcher(CoreProperties.getString(CoreProperties.Label_Dataset) + "_textField"), datasetName);
	}
}
